package service

import (
	"GIN-API/internal/models"
	"GIN-API/internal/repository"
)

// UserService 定义用户服务层结构体
type UserService struct {
	userRepo *repository.UserRepository
}

// NewUserService 创建用户服务层实例
func NewUserService(userRepo *repository.UserRepository) *UserService {
	return &UserService{
		userRepo: userRepo,
	}
}

// CreateUser 创建用户
func (us *UserService) CreateUser(user *models.User) error {
	return us.userRepo.CreateUser(user)
}

// GetUserByID 根据用户 ID 获取用户信息
func (us *UserService) GetUserByID(id uint) (*models.User, error) {
	return us.userRepo.GetUserByID(id)
}

// GetUserByUsername 根据用户名获取用户信息
func (us *UserService) GetUserByUsername(username string) (*models.User, error) {
	return us.userRepo.GetUserByUsername(username)
}

// UpdateUser 更新用户信息
func (us *UserService) UpdateUser(user *models.User) error {
	return us.userRepo.UpdateUser(user)
}

// DeleteUser 根据用户 ID 删除用户
func (us *UserService) DeleteUser(id uint) error {
	return us.userRepo.DeleteUser(id)
}
